home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / GENCSRC.ZIP / UNION1.C < prev    next >
C/C++ Source or Header  |  1987-11-21  |  478b  |  20 lines

  1.                                          /* Chapter 11 - Program 5 */
  2. main()
  3. {
  4. union {
  5.    int value;     /* This is the first part of the union */
  6.    struct {
  7.       char first;   /* These two values are the second     */
  8.       char second;
  9.    } half;
  10. } number;
  11.  
  12. long index;
  13.  
  14.    for (index = 12;index < 300000;index += 35231) {
  15.       number.value = index;
  16.       printf("%8x %6x %6x\n",number.value, number.half.first,
  17.               number.half.second);
  18.    }
  19. }
  20.